using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace TestWebApp.DataAccess.Common
{
    [ContractClassFor(typeof(IRepository<>))]
    abstract class RepositoryContract<T>: IRepository<T> where T : class
    {
        public IEnumerable<T> GetAll()
        {
            return default(IEnumerable<T>);
        }

        public T GetById(object id)
        {
            Contract.Requires<ArgumentNullException>(id != null);

            return default(T);
        }

        public T Insert(T obj)
        {
            Contract.Requires<ArgumentNullException>(obj != null);
            Contract.Ensures(Contract.Result<T>() != null);

            return default(T);
        }

        public T Update(T obj)
        {
            Contract.Requires<ArgumentNullException>(obj != null);
            Contract.Ensures(Contract.Result<T>() != null);

            return default(T);
        }

        public void DeleteById(object id)
        {
            Contract.Requires<ArgumentNullException>(id != null);
        }

        public void Delete(T obj)
        {
            Contract.Requires<ArgumentNullException>(obj != null);
        }

        public abstract void Save();

        public void Attach(T obj)
        {
            Contract.Requires<ArgumentNullException>(obj != null);
        }
    }
}